package cn.exrick.xboot.common.exception;

import cn.exrick.xboot.common.exception.abs.AbstractBaseExceptionEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * Created with IntelliJ IDEA.
 *业务异常
 * @Auther: njp
 * @Date: 2020/09/07/17:20
 * @Description:
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ServiceException extends RuntimeException{
    private Integer code;

    private String errorMessage;

    public ServiceException(Integer code, String errorMessage) {
        super(errorMessage);
        this.code = code;
        this.errorMessage = errorMessage;
    }

    public ServiceException(AbstractBaseExceptionEnum exception) {
        super(exception.getMessage());
        this.code = exception.getCode();
        this.errorMessage = exception.getMessage();
    }
}
